package cn.tedu.api;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

//测试 collections工具类--为集合提供的各种方法
public class Test1_Collections {
    //main
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(9);
        list.add(1);
        list.add(6);
        list.add(3);
        list.add(7);
        System.out.println(list);

        //优化
        Collections.addAll(list,9, 1, 6, 3, 7);
        System.out.println(list);

        System.out.println(Collections.max(list));
        System.out.println(Collections.min(list));

        Collections.reverse(list);
        System.out.println(list);

        Collections.replaceAll(list,9,1);
        System.out.println(list);
    }
}
